package com.qmx.qmxapp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.qmx.qmxapp.R;
import com.qmx.qmxapp.base.BaseActivity;
import com.qmx.qmxapp.callback.DialogCallback;
import com.qmx.qmxapp.constant.AppConstant;
import com.qmx.qmxapp.constant.ComParamContact;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author ChengXiangtong
 * @create 2018/11/6
 * @Describe 个人信息修改
 */
public class PersonInfoActivity extends BaseActivity {

    RelativeLayout rv_head_icon;
    @BindView(R.id.tv_mine_name)
    TextView tv_mine_name;
    @BindView(R.id.tv_mine_phone)
    TextView tv_mine_phone;
    @BindView(R.id.tv_mine_chang_password)
    TextView tv_mine_chang_password;
    @BindView(R.id.tv_mine_email)
    TextView tv_mine_email;
    @BindView(R.id.tv_mine_login_out)
    TextView tv_mine_login_out;

    private String token = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_person_info);
        ButterKnife.bind(this);

        rv_head_icon = findViewById(R.id.rv_head_icon);
        rv_head_icon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    @OnClick({R.id.tv_mine_name, R.id.tv_mine_phone, R.id.tv_mine_chang_password, R.id.tv_mine_email, R.id.tv_mine_login_out})
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()) {
            case R.id.tv_mine_name:
                intent.setClass(this, PersonInfoActivity.class);
                return;
            case R.id.tv_mine_phone:
                intent.setClass(this, PersonInfoActivity.class);
                return;
            case R.id.tv_mine_login_out:
                doLogout();
                return;
            case R.id.tv_mine_chang_password:
                intent.setClass(this, MineChangePasswordActivity.class);
                break;
            case R.id.tv_mine_email:
                intent.setClass(this, EmailVerifyActivity.class);
                break;
        }
        startActivity(intent);
    }

    private void doLogout() {
        OkGo.<String>post(AppConstant.Url + ComParamContact.Logout.PATH)
                .params(ComParamContact.Logout.TOKEN, token)
                .execute(new DialogCallback<String>(this) {

                    @Override
                    public void onSuccess(Response<String> response) {
                        showToast(response.body());
//                            handleResponse(response);
                    }

                    @Override
                    public void onError(Response<String> response) {
                        showToast("接口有问题");
//                            handleError(response);
                    }
                });
    }
}
